# Maintainer: Tim Meusel <tim@bastelfreak.de>

_gemname='spdx-licenses'
pkgname="ruby-${_gemname}"
pkgver=1.3.0
pkgrel=1
pkgdesc='Tool to check the validity of Puppet metadata.json files'
arch=('any')
url="https://github.com/domcleal/${_gemname}"
license=('MIT')
depends=('ruby')
makedepends=('ruby-rdoc' 'ruby-rake' 'ruby-minitest' 'ruby-mocha')
options=('!emptydirs')
source=("${url}/archive/v${pkgver}/${_gemname}-v${pkgver}.tar.gz")
sha512sums=('f99f83191676a89beeb65f8862e9101647e98ce8f8d8d61e077fb8868683a12e5adcf1d45e0f7581e81a20244fb1085e6f632cda27b5bb304307bf6f870dcda2')

prepare() {
  cd "${srcdir}/${_gemname}-${pkgver}"

  sed --in-place 's|git ls-files|find|' "${_gemname}.gemspec"
}

build() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  rake
}

package() {
cd "${srcdir}/${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}
